Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Removes default dependency to Zend\StdLib #21

Conversation

heiglandreas
Copy link
Member

This commit removes the default dependency to the \Zend\StdLib\ErrorHandler by replacing it with a
\Zend\Ldap\ErrorHandler that delegates the error handling to an injectable ErrorHandler.

That way the tests can use \Zend\StdLib\ErrorHandler and silence errors during the tests whereas in a live environment no error-suppression is used by default.

Other ErrorHandlers can be used by creating a class that implements \Zend\Ldap\ErrorHandlerInterface and injecting an instance of that class as ErrorHandler using \Zend\Ldap\ErrorHandler::setErrorHandler()

The main aim would be to get rid of external dependencies to make the component as independent as possible and allow a more widespread usage.

This has been influenced by zendframework/zendframework#7497 and symfony/symfony-docs#5756

/**
* Setup autoloading
*/
require __DIR__ . '/../vendor/autoload.php';

/**
* Setting the Zend\StdLib/ErrorHandler as default ErrorHandler
*/
Zend\Ldap\ErrorHandler::setErrorHandler(new ZendTest\Ldap\ErrorHandler());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the default ErrorHandler does nothing at all but the tests seem to depend on error-suppression I've added that one to get the tests running under the same conditions as before. I was thinking of adding that line to src/Ldap.php (at the very end) so that that's set as default error handler and users can overwrite that with their own implementation. On the other hand that would mean that the dependency to Zend\StdLib\ErrorHandler would not be eliminated.

@felipsmartins
Copy link

Looks nice!

},
"require-dev": {
"zendframework/zend-config": "~2.5",
"zendframework/zend-eventmanager": "~2.5",
"fabpot/php-cs-fixer": "1.7.*",
"phpunit/PHPUnit": "~4.0"
"phpunit/PHPUnit": "~5.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use "phpunit/phpunit": "~4.0|~5.0" then the dependency of php >=5.6 will use phpunit 5, and for php 5.5 will still uses phpunit 4

@heiglandreas heiglandreas changed the title [WIP] Removes default dependency to Zend\StdLib Removes default dependency to Zend\StdLib Jan 14, 2016
@gianarb
Copy link

gianarb commented Jan 14, 2016

👍

This commit removes the default dependency to the
```\Zend\StdLib\ErrorHandler``` by replacing it with a
```\Zend\Ldap\ErrorHandler```
that delegates the error handling to an injectable ErrorHandler.

That way the tests can use ```\Zend\StdLib\ErrorHandler``` and silence errors
during the tests whereas in a live environment no error-suppression is
used by default.

Other ErrorHandlers can be used by creating a class that implements
```\Zend\Ldap\ErrorHandlerInterface``` and injecting an instance of that class
as ErrorHandler using ```\Zend\Ldap\ErrorHandler::setErrorHandler()```
This commit adds some space and newlines
@heiglandreas heiglandreas force-pushed the feature/removeExternalDependencies branch from b6829cb to 81bf78b Compare April 20, 2016 15:38
@heiglandreas heiglandreas added this to the 2.7.0 milestone Apr 21, 2016
@heiglandreas heiglandreas self-assigned this Apr 21, 2016
@heiglandreas heiglandreas merged commit 81bf78b into zendframework:master Apr 21, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants